#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2023/09/06 15:48
# @Author  : suo.tianbao
# @Email   : suo.tianbao@vpclub.cn
# @File    : Schedule.py
class Schedule:
    id = 0
    job_name = None
    job_group_name = None
    job_class = None
    trigger_name = None
    trigger_group_name = None
    cron_expression = None
    call_back = None

    def __init__(self, job_name, job_group_name, job_class, trigger_name, trigger_group_name, cron_expression,
                 call_back):
        self.job_name = job_name
        self.job_group_name = job_group_name
        self.job_class = job_class
        self.trigger_name = trigger_name
        self.trigger_group_name = trigger_group_name
        self.cron_expression = cron_expression
        self.call_back = call_back

    @staticmethod
    def split_params(params):
        g_param = []
        if len(params.job_name) > 0:
            g_param.append('`jobName`=' + "\'" + params.job_name + "\'")
        if len(params.job_group_name) > 0:
            g_param.append('`jobGroupName`=' + "\'" + params.job_group_name + "\'")
        if len(params.job_class) > 0:
            g_param.append('`jobClass`=' + "\'" + params.job_class + "\'")
        if len(params.trigger_name) > 0:
            g_param.append('`triggerName`=' + "\'" + params.trigger_name + "\'")
        if len(params.trigger_group_name) > 0:
            g_param.append('`triggerGroupName`=' + "\'" + str(params.trigger_group_name) + "\'")
        if len(params.cron_expression) > 0:
            g_param.append('`cronExpression`=' + "\'" + str(params.cron_expression) + "\'")
        if len(params.call_back) > 0:
            g_param.append('`callBack`=' + "\'" + str(params.call_back) + "\'")
        return ','.join(str(i) for i in g_param)
